1. The Field of the Invention
The present invention relates to systems and methods for providing multi-pass rendering of three-dimensional graphics. More specifically, the present invention is directed to systems and methods for utilizing one or more texture units and a plurality of associated frame buffers in a rendering pipeline to perform multiple rendering passes, to support the use and storage of extra temporary data, and to blend data from multiple texture maps that is applied to a polygon so as to model a three-dimensional object.
2. Background and Related Art
Adding realism to computer graphics involves rendering an object that has three-dimensional characteristics on a two-dimensional display device. Such three-dimensional characteristics include shadows and variations in color and shade of the object. For each desired three-dimensional characteristic, a specific texture map is applied to a frame of polygons in order to render the object. When multiple characteristics are desired, the corresponding texture maps are blended. Therefore, the blending and applying of various corresponding texture maps renders the object as having the desired three-dimensional characteristics, such as any desired color, pattern, appearance, etc.
A conventional technique for applying multiple texture maps to render a three-dimensional image includes utilizing a single texture unit and a single frame buffer. As multiple passes are performed, the frame buffer is used as the temporary data storage between passes. While such a technique adequately applies light or shadow maps on opaque objects, the conventional technique cannot be adequately utilized for transparent objects since temporary data and current destination pixel data cannot co-exist under the conventional technique.
Another technique for applying multiple texture maps to render a three-dimensional image uses a rendering pipeline that includes a texture unit for every texture map that is applied. The texture units are placed in series within the rendering pipeline, which assembles one or more polygons to represent an object having three-dimensional characteristics and applies multiple texture maps to the assembled polygon. Many effects are only renderable if one or more temporary pieces of data are allowed to exist between texture units of a pipeline. Thus, under this conventional technique, an additional piece of temporary data is passed between the texture units of the rendering pipeline and is fully consumed by the end of the pipeline.
By way of example, FIG. 1 illustrates a conventional rendering pipeline that includes vertex unit 10, setup unit 11, edge walk unit 12, span walk unit 13, z-buffer 14, texture units 15, destination blender 18, and frame buffer 19. In the rendering pipeline, vertex unit 10 assembles data describing the values at each vertex of a polygon. The data includes three-dimensional coordinates, which represent each of the polygons that together model a three-dimensional object, and texture coordinates, the values for which are determined later in the pipeline through a series of texture units. Vertex unit 10 provides the assembled data to setup unit 11, which generates parametric function coefficients for an interpolation of intermediary points between the three-dimensional coordinates. Edge walk unit 12 receives the output of setup unit 11 and determines the starting pixel and the value of the starting pixel for each horizontal row of pixels lying within the bounds of the polygon. Span walk unit 13 then determines the values for all of the pixels for each horizontal row within the polygon. The values determined by edge walk unit 12 and span walk unit 13 are provided to z-buffer 14, which determines whether the pixels are occluded or visible, so that only currently visible pixels are drawn.
A set of texture coordinates representing the various layers of textures that are to be applied to the generated polygons are passed through a series of texture units 15. The number of texture units in series corresponds to the number of texture layers that are to be applied. In the example of FIG. 1, five texture layers are applied to the generated polygons. Other conventional rendering pipelines may include any number of texture units in series to apply the corresponding number of texture maps.
In FIG. 1, each texture unit 15 receives a series of texture coordinate sets for each pixel, performs a texture map look up to obtain the values of the coordinate sets related to a texture map, and performs a blending operation that may include blending the obtained values with values from one or more previous texture maps. Temporary data is passed between the texture units 15 and is fully consumed by the end of the rendering pipeline.
Therefore, with reference to the series of texture units 15 of FIG. 1, texture unit 15a receives a series of texture coordinate sets from z-buffer 14 for each pixel. An example of a series of texture coordinate sets for a given pixel is (u0,v0), (u1,v1), (u2,v2), (u3,v3), and (u4,v4), where (u0,v0) is the texture coordinate set for the first texture map, (u1,v1) is the texture coordinate set for the second texture map, (u2,v2) is the texture coordinate set for the third texture map, (u3,v3) is the texture coordinate set for the fourth texture map, and (u4,v4) is the texture coordinate set for the fifth texture map. Because the texture units are in series, the full complement of texture coordinate sets, which, in this example include (u0,v0), (u1,v1), (u2,v2), (u3,v3), and (u4, v4), are transmitted from z-buffer 14 to texture unit 15a. In this manner, each of the texture units 15a–15e can select the texture coordinate set it needs to perform a texture map look up operation.
The following example illustrates the conventional technique that is currently performed for each pixel. Texture unit 15a takes the texture coordinate set (u0,v0) corresponding to the first texture map and performs a look up at texture cache 16a to obtain the texture values for the pixel. Texture blender 17a performs a blending operation to apply the texture values to the pixel corresponding to the first texture map.
Texture unit 15b receives the series of texture coordinate sets for the pixel from texture unit 15a. The texture coordinate set (u1,v1), which corresponds to the second texture map, is selected by texture unit 15b and a look up is performed at texture cache 16b to obtain the texture values for the pixel. Texture blender 17b then performs a blending operation, which includes blending the texture values corresponding to texture coordinates (u0,v0) and (u1,v1), to apply the texture values to the pixel corresponding to the first and second texture maps.
Texture unit 15c receives from texture unit 15b the series of texture coordinate sets for the pixel. The texture coordinate set (u2,v2), which corresponds to the third texture map, is selected by texture unit 15c and a look up is performed at texture cache 16c to obtain the texture values for the pixel. Texture blender 17c performs a blending operation, which includes blending the texture values corresponding to texture coordinates (u0,v0), (u1,v1) and (u2,v2), to apply the texture values to the pixel corresponding to the first, second and third texture maps.
Texture unit 15d receives the series of texture coordinate sets for the pixel from texture unit 15c. The texture coordinate set (u3,v3), which corresponds to the fourth texture map, is selected by texture unit 15d and a look up is performed at texture cache 16d to obtain the texture values for the pixel. Texture blender 17d performs a blending operation, which includes blending the texture values corresponding to texture coordinates (u0,v0), (u1,v1), (u2,v2) and (u3,v3), to apply the texture values to the pixel corresponding to the first, second, third, and fourth texture maps.
Texture unit 15e receives the series of texture coordinate sets for the pixel from texture unit 15d. The texture coordinate set (u4,v4), which corresponds to the fifth texture map, is selected by texture unit 15e and a look up is performed at texture cache 16e to obtain the texture values for the pixel. Texture blender 17e performs a blending operation, which includes blending the texture values corresponding to texture coordinates (u0,v0), (u1,v1), (u2,v2), (u3,v3) and (u4,v4), to apply the texture values to the pixel corresponding to the first, second, third, and fourth texture maps.
The process explained above is performed for each of the pixels and the composite texture values, which are the blended texture values for each pixel corresponding to texture coordinates (u0,v0), (u1,v1), (u2,v2), (u3,v3) and (u4,v4). After texturing, the pixels are optionally modified by the destination blender 18, which applies optional fog blending, iterated specular blending, and/or alpha blending to the pixels that are then mapped to a frame buffer 19. Once the completed values for all of the pixels are mapped to frame buffer 19, the display device is refreshed with the rendered image.
Another conventional technique for applying multiple texture maps to render a three-dimensional image utilizes a rendering pipeline, such as the rendering pipeline illustrated in FIG. 1, and an extra piece of temporary data that only exists between texture stages. However, with this technique it is possible for the regular multi-texturing type of temporary data to concurrently exist between texture stages since previous texture stages could have other texture lookup proceeding. As such, there are up to two pieces of temporary inter-texture stage data and one piece of destination pixel data in the frame buffer.
Due to significant and sometimes prohibitive amounts of computing resources that are required, including a high demand for memory, conventional rendering techniques are limited to typically two or three texture units rather than the maximum number of eight. As such, the conventional techniques only allow for three stages of multi-texturing and the conventional techniques are limited to one pass through the rendering pipeline unless no extra temporary data is required after each pass, the pixels are opaque, and there is no pixel discarding occurring during each texture stage (e.g. color keying).